import MyCrypto from "../../MyCrypto";

export interface IInsertData {
    [index:string]:string
}

export default class Insert{
    private _knex;
    private _crypto = new MyCrypto();
    constructor(props){
        const {knex} = props;
        this._knex = knex;
    }

    insert(TABLE_NAME:string, DATA:IInsertData){
        const _DATA = this.encode(DATA);

        return this._knex(TABLE_NAME).insert(_DATA).catch((e)=>{
            throw e;
        });
    }

    private encode(DATA:IInsertData){
       return this._crypto.dataEncode(DATA);
    }
}
